#include <iostream>
#include <math.h>

typedef struct {
    double re,im;
} complex;

const complex ZERO = {0.0, 0.0};

inline void afisare(complex x);
double modul (complex x);
double arg(complex x);

complex adcomplex (complex *a, complex *b);
complex adcomplex (complex &a, complex &b);
complex diff (complex a, complex b);
complex diff (complex *a, complex *b);
void print (complex p);




inline void afisare(complex x)
{
    
    std::cout<<"\n"<<x.re;
    if (x.im > 0)
        std::cout<<"+";
    std::cout<<x.im;
}

double modul (complex x)
{
    return sqrt( x.im*x.im + x.re*x.re);
}

double arg(complex x)
{
    return atan(x.im/x.re);
}

complex adcomplex(complex *a, complex *b)
{
    double x,y;
    x=a->re+b->re;
    y=a->im+b->im;
    complex s={x,y};
    return s;
}
complex adcomplex(complex &a, complex &b)
{
    double x,y;
    x=a.re+b.re;
    y=a.im+b.im;
    complex s={x,y};
    return s;
}

complex diff (complex a, complex b)
{
    double x,y;
    x=a.re-b.re;
    y=a.im-b.im;
    complex z={x,y};
    return z;
}
complex diff( complex *a, complex *b)
{
    double x,y;
    x=a->re-b->re;
    y=a->im-b->im;
    complex z={x,y};
    return z;
}

void print(complex p=ZERO)
{
    std::cout<<"x.real"<<p.re<<"x.imag"<<p.im;
    
}
int main()
{
    complex x={3.2, 2.3},y={5.3,7.34},rez;
    afisare(ZERO);
    std::cout<<"\n|Z|="<<modul(x)<<"\n";
    std::cout<<"arg="<<arg(x);
    rez=adcomplex(x,y);
    afisare(rez);
    rez=adcomplex(&x,&y);
    afisare(rez);
    rez=adcomplex(&x,&y);
    afisare(rez);
    rez=diff(x,y);
    afisare(rez);
    rez=diff(&x,&y);
    afisare(rez);
    return 0;
    
    
}